package Schema::Result::Template;

use strict;
use warnings;
use utf8;

use base qw/DBIx::Class::Core/;

__PACKAGE__->table('Template');
__PACKAGE__->add_columns( 
    Id => { data_type => 'integer', is_auto_increment => 1 },
    Name  => {},
    Content => {},
    Comment  => {},
);
__PACKAGE__->set_primary_key('Id');

# 创建模板
sub Create{
    my ($class, $schema, $params) = @_;

    my $newTemplate = $schema->resultset('Template')->create($params);

    return $newTemplate;
}

# 修改模板
sub Modify{
    my ($self, $params) = @_;
    if(defined $params->{Name}){
        $self->Name($params->{Name});
    }
    if(defined $params->{Content}){
        $self->Content($params->{Content});
    }
    if(defined $params->{Comment}){
        $self->Comment($params->{Comment});
    }

    $self->update;
}

# 删除
sub Delete {
    my ($self) = @_;

    $self->delete;
}

1;
